home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / BC_TI.ARJ / TI706.ASC < prev    next >
Text File  |  1992-02-25  |  3KB  |  133 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.   PRODUCT  :  Borland C++                            NUMBER  :  706
  9.   VERSION  :  2.0
  10.        OS  :  DOS
  11.      DATE  :  February 25, 1992                        PAGE  :  1/2
  12.  
  13.     TITLE  :  Fix for BCWDEMO Line Drawing Example
  14.  
  15.  
  16.  
  17.  
  18.   BCWDEMO does not draw lines appropriately if drawn from lower
  19.   right to upper left. The below replacement code fixes the
  20.   problem.
  21.  
  22.   Basically, the code ordering must be changed and a new
  23.   conditional statement substituted for the old. Below code --
  24.   replacement function -- fixes the line drawing problem.
  25.  
  26.   /****************************************************************
  27.    * function DoLButtonUp
  28.    *    When the left mouse button is released, this routine
  29.    *    allows other windows to receive mouse messages and saves
  30.    *    the position of the mouse as the other corner of a bounding
  31.    *    rectangle for the shape.
  32.    ***************************************************************/
  33.  
  34.   void DoLButtonUp(HWND hWnd, LONG lParam)
  35.   {
  36.       ReleaseCapture();
  37.  
  38.       /*
  39.        * if the origin of the line has changed, it should be drawn
  40.        * from upper right to lower left and therefore has negative
  41.        * slope.  Otherwise it will have positive slope.
  42.        */
  43.  
  44.       if (CurrentShape == LINE)
  45.         thisShape[CurrentPoint].Slope =
  46.         (thisShape[CurrentPoint].Points.left < LOWORD(lParam) &&
  47.          thisShape[CurrentPoint].Points.top < HIWORD(lParam)) ||
  48.         (thisShape[CurrentPoint].Points.left > LOWORD(lParam) &&
  49.          thisShape[CurrentPoint].Points.top > HIWORD(lParam))
  50.          ? 1 : -1;
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.   PRODUCT  :  Borland C++                            NUMBER  :  706
  75.   VERSION  :  2.0
  76.        OS  :  DOS
  77.      DATE  :  February 25, 1992                        PAGE  :  2/2
  78.  
  79.     TITLE  :  Fix for BCWDEMO Line Drawing Example
  80.  
  81.  
  82.  
  83.  
  84.       /*
  85.        * For rectangles to work with the IntersectRect function,
  86.        * they must be stored as left, top, right, bottom.
  87.        */
  88.       SetRect(&thisShape[CurrentPoint].Points,
  89.               min(thisShape[CurrentPoint].Points.left,
  90.               LOWORD(lParam)),
  91.               min(thisShape[CurrentPoint].Points.top,
  92.               HIWORD(lParam)),
  93.               max(thisShape[CurrentPoint].Points.left,
  94.               LOWORD(lParam)),
  95.               max(thisShape[CurrentPoint].Points.top,
  96.                  HIWORD(lParam)));
  97.       /*
  98.        * Mark this region on the window as
  99.        * needing redrawing and force an update.
  100.        */
  101.       InvalidateRect(hWnd, &thisShape[CurrentPoint].Points, 0);
  102.       UpdateWindow(hWnd);
  103.       mouseDown = 0;
  104.       oldx = -1;
  105.       oldy = -1;
  106.   }
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.